package com.cn.base;

import com.cn.Dao.*;
import com.cn.entity.*;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Util<T> {
    public static byte[] file2byte(File file)throws Exception{
        byte[] buffer=new byte[(int)file.length()];
        FileInputStream fis=new FileInputStream(file);
        ByteArrayOutputStream bos=new ByteArrayOutputStream();
        byte[] b=new  byte[4096];
        int n;
        while (((n=fis.read())!=-1)){
            bos.write(b,0,n);
        }
        fis.close();
        bos.close();
        buffer=bos.toByteArray();
        return buffer;
    }
    public static String changeDate(Date date){
        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateString=format.format(date);
        return dateString;
    }
    public static String changeLike(String s){
        return ("%"+s+"%");
    }
    public static int stringOfInt(String s){return s.equals("")?-1:Integer.parseInt(s);}

}
